var dangqian = '11';
var nowpage = 1

var form1 = {
    size: 10,
    page: 1
    // contacts: "",
    // merchantNo: "",
    // state: "",
    // telephone: "",
    // username: "",
}
var form2 = {
total: 2000,
pageSize: 10,
showTotal: true,
showTo: true,
change: function ( i ) {
    createContent( i );
}
}
var $content = $( ".content" );
console.log(form1)
function getTableData(){
    // var form_showall = {
    //     contacts: form1.contacts,
    //     merchantNo: form1.merchantNo,
    //     state: form1.state,
    //     telephone: form1.telephone,
    //     username: form1.username,
    // }
    // console.log(form1.page,form1.size)
    $.ajax({
    url:initObj.url + "/api/rechargeInfo/rechargeInfo/" + form1.page + '/' + form1.size,
    // data:JSON.stringify(form_showall),
    // data:form1,
    datatype:'json',
    type:'get',
    beforeSend: function(request) {
        request.setRequestHeader("token", form.token);
    //    console.log(form.token)
    },
    // contentType: "application/json;charset=utf-8",
    success:function(res){
        console.log(res)
        document.getElementById('selectAll').innerHTML = ""
        for(var i=0;i<res.data.content.length;i++){
            document.getElementById('selectAll').innerHTML += "<li><span style='display:inline-block;width:10vw'>"
            +res.data.content[i].name+"</span><span style='display:inline-block;width:10vw'>"
            +res.data.content[i].bankCard+"</span><span style='display:inline-block;width:10vw'>"
            +res.data.content[i].bankName+"</span><span style='display:inline-block;width:17vw'>"
            +res.data.content[i].bankNameSon+"</span><button style='color:#474c82;border:none;background-color:transparent' onclick='update_state("
            +res.data.content[i].id+")'>已"+res.data.content[i].state+"</button></li>"
            // if(res.data.content[i].state == '正常'){
            //     document.getElementsByClassName('state')[i].style.color = '#63c409'
            // }else if(res.data.userDTO[i].state == '异常'){
            //     document.getElementsByClassName('state')[i].style.color = '#e0d42e'
            // }else{
            //     document.getElementsByClassName('state')[i].style.color = '#f95959'
            // }
        }
        if(form2.total !== res.data.totalElements){
            form2.total = res.data.totalElements
            Helper.ui.page("#page-3", form2);
            nowpage++
        }
    }
    })
}
Helper.ui.page("#page-3", form2);
getTableData()
function createContent (i) {
form1.page = i
getTableData()
}
// function changeinfo(id,value){
// form1[id] = value
// // console.log(form1)
// }
function search(){
getTableData()
}
function update_state(id){
    $.ajax({
                url:initObj.url + "/api/rechargeInfo/rechargeInfoState/" + id,
                // data:JSON.stringify(),
                // data:form1,
                datatype:'json',
                type:'put',
                beforeSend: function(request) {
                    request.setRequestHeader("token", form.token);
                //    console.log(form.token)
                },
                // contentType: "application/json;charset=utf-8",
                success:function(res){
                    console.log(res)
                    alert(res.msg)
                    getTableData()
                }
            })
}


// 新增银行卡

function create_bankcard(){
    document.getElementById('create_bankcard_show').style.display = 'block'
}
function create_user_close(){
    document.getElementById('create_bankcard_show').style.display = 'none'
}
function create_bankcard_OK(){
    var form_create = {
        bankCard:bankCard.value,
        bankName:bankName.value,
        bankNameSon:bankNameSon.value,
        name:name111.value,
    }   
    $.ajax({
        url:initObj.url + "/api/rechargeInfo/addOneBankCard",
        data:JSON.stringify(form_create),
        // data:form1,
        datatype:'json',
        type:'post',
        beforeSend: function(request) {
            request.setRequestHeader("token", form.token);
        //    console.log(form.token)
        },
        contentType: "application/json;charset=utf-8",
        success:function(res){
            console.log(res)
            alert(res.msg)
        }
    })
    create_user_close()
    getTableData(form1)
}